package com.itcat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcat.mysql.pojo.CmsPrefrenceAreaProductRelation;
import com.itcat.mysql.pojo.PmsProductFullReduction;
import com.itcat.mysql.pojo.PmsProductLadder;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author 小心触碰的电脑
* @description 针对表【pms_product_ladder(产品阶梯价格表(只针对同商品))】的数据库操作Mapper
* @createDate 2022-04-03 16:23:09
* @Entity com.itcat.mysql.pojo.PmsProductLadder
*/
@Mapper
public interface PmsProductLadderMapper extends BaseMapper<PmsProductLadder> {

    @Insert({"<script> " +
            "insert into pms_product_ladder  ( product_id, count, discount , price)values" +
            " <foreach collection='list' item='item' index='index' separator=',' > " +
            "( #{item.productId}, #{item.count}, #{item.discount}, #{item.price})" +
            "</foreach>" +
            "</script>"})
    int batchInsert(@Param("list") List<PmsProductLadder> list);

    @Update({"<script> " +
            "<foreach collection='list' item='item' index='index' separator=';'> " +
            "UPDATE pms_product_ladder " +
            "SET product_id = #{item.productId}, count=#{item.count}, discount=#{item.discount} , price=#{item.price} " +
            "WHERE id = #{item.id} </foreach> </script>"})
    int batchUpdate(@Param("list") List<PmsProductLadder> list);

}
